package com.crm.service.impl;

import com.crm.Mapper.BusinessMapper;
import com.crm.entity.Business;
import com.crm.page.CluePage;
import com.crm.service.BusinessService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
@AllArgsConstructor
public class BusinessServiceImpl implements BusinessService {
    private final BusinessMapper businessMapper;
    @Override
    public void insert(Business business) {
        log.info("新增商机:{}",business);
        businessMapper.insert(business);
    }

    @Override
    public PageInfo<Business> PageBusinessList(CluePage BusinessPage) {
        PageHelper.startPage(BusinessPage.getPageNum(), BusinessPage.getPageSize());
        List<Business> businesses = businessMapper.selectByBusinessList(BusinessPage.getBeginCreateTime(),BusinessPage.getEndCreateTime());
        log.info("商机分页查询{}",businesses);
        return new PageInfo<>(businesses);
    }
}
